﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Finance.Data;
using Finance.Data.Entities;

namespace Finance.Controllers
{
	public interface IDocumentBaseController
	{
		IEnumerable<string> GetDocumentSubTypesNames(DocumentType documentType);
		IList<IContractor> GetContractors();
		IContractor CreateContractor(string contractorName);
	}

	internal class DocumentBaseController : IDocumentBaseController
	{
		protected readonly FinanceDataBase FinanceDataBase;

		public DocumentBaseController(FinanceDataBase financeDataBase)
		{
			FinanceDataBase = financeDataBase;
		}

		public IEnumerable<string> GetDocumentSubTypesNames(DocumentType documentType)
		{
			return FinanceDataBase.DocumentSubTypes.RetrieveNames(documentType);
		}

		public IList<IContractor> GetContractors()
		{
			return FinanceDataBase.Contractors.GetAll().ToList();
		}

		public IContractor CreateContractor(string contractorName)
		{
			return FinanceDataBase.Contractors.Create(contractorName);
		}
	}
}
